package com.turing.post.salesmanage.util;

import java.io.Serializable;
import java.math.BigInteger;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 * @销售单售卡明细
 * @author zxl
 * @date 2012-12-17
 */
@SuppressWarnings("serial")
@Entity
@Table(name = "SALEORDERCARDDETAIL")
@IdClass(SaleOrderCardDetail.class)
public class SaleOrderCardDetail implements Serializable {
	/**
	 * 销售单ID
	 */
	private BigInteger saleOrderId;

	/**
	 * 卡种类
	 */
	private BigInteger cardClassicId;
	/**
	 * 批次号
	 */
	private String batchNo;
	/**
	 * 起始序号
	 */
	private String startCardSeqNo;
	/**
	 * 终止序号
	 */
	private String endCardSeqNo;
	/**
	 * 起始卡号
	 */
	private String startCardNo;
	/**
	 * 终止卡号
	 */
	private String endCardNo;
	/**
	 * 售卡张数
	 */
	private Integer cardCount;
	/**
	 * 初始卡内金额
	 */
	private Integer initDeposit;
	/**
	 * 本行小计金额
	 */
	private BigInteger orderLineTotal;
	/**
	 * 备注
	 */
	private String remark;

	/**
	 * 销售员领卡单单号
	 */
	private String salesGetCardOrderNo;

	public SaleOrderCardDetail() {
		super();
	}

	@Id
	@Column(name = "SALEORDERID", nullable = false)
	public BigInteger getSaleOrderId() {
		return saleOrderId;
	}

	public void setSaleOrderId(BigInteger saleOrderId) {
		this.saleOrderId = saleOrderId;
	}

	@Id
	@Column(name = "BATCHNO", nullable = false)
	public String getBatchNo() {
		return batchNo;
	}

	public void setBatchNo(String batchNo) {
		this.batchNo = batchNo;
	}

	@Id
	@Column(name = "STARTCARDSEQNO", nullable = false)
	public String getStartCardSeqNo() {
		return startCardSeqNo;
	}

	public void setStartCardSeqNo(String startCardSeqNo) {
		this.startCardSeqNo = startCardSeqNo;
	}

	@Column(name = "cardClassicId")
	public BigInteger getCardClassicId() {
		return cardClassicId;
	}

	public void setCardClassicId(BigInteger cardClassicId) {
		this.cardClassicId = cardClassicId;
	}

	@Column(name = "ENDCARDSEQNO", nullable = false)
	public String getEndCardSeqNo() {
		return endCardSeqNo;
	}

	public void setEndCardSeqNo(String endCardSeqNo) {
		this.endCardSeqNo = endCardSeqNo;
	}

	@Column(name = "STARTCARDNO", nullable = false)
	public String getStartCardNo() {
		return startCardNo;
	}

	public void setStartCardNo(String startCardNo) {
		this.startCardNo = startCardNo;
	}

	@Column(name = "ENDCARDNO", nullable = false)
	public String getEndCardNo() {
		return endCardNo;
	}

	public void setEndCardNo(String endCardNo) {
		this.endCardNo = endCardNo;
	}

	@Column(name = "CARDCOUNT", nullable = false)
	public Integer getCardCount() {
		return cardCount;
	}

	public void setCardCount(Integer cardCount) {
		this.cardCount = cardCount;
	}

	@Column(name = "INITDEPOSIT", nullable = false)
	public Integer getInitDeposit() {
		return initDeposit;
	}

	public void setInitDeposit(Integer initDeposit) {
		this.initDeposit = initDeposit;
	}

	@Column(name = "ORDERLINETOTAL", nullable = false)
	public BigInteger getOrderLineTotal() {
		return orderLineTotal;
	}

	public void setOrderLineTotal(BigInteger orderLineTotal) {
		this.orderLineTotal = orderLineTotal;
	}

	@Column(name = "REMARK")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	/**
	 * 数据库中不存在字段
	 * 
	 * @return
	 */
	@Transient
	public String getSalesGetCardOrderNo() {
		return salesGetCardOrderNo;
	}

	public void setSalesGetCardOrderNo(String salesGetCardOrderNo) {
		this.salesGetCardOrderNo = salesGetCardOrderNo;
	}

	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime
				* result
				+ ((this.getBatchNo() == null) ? 0 : this.getBatchNo()
						.hashCode());
		result = prime
				* result
				+ ((this.getSaleOrderId() == null) ? 0 : this.getSaleOrderId()
						.hashCode());
		result = prime
				* result
				+ ((this.getStartCardSeqNo() == null) ? 0 : this
						.getStartCardSeqNo().hashCode());
		return result;
	}

	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		SaleOrderCardDetail other = (SaleOrderCardDetail) obj;
		if (this.getBatchNo() == null) {
			if (other.getBatchNo() != null)
				return false;
		} else if (!this.getBatchNo().equals(other.getBatchNo()))
			return false;
		if (this.getSaleOrderId() == null) {
			if (other.getSaleOrderId() != null)
				return false;
		} else if (!this.getSaleOrderId().equals(other.getSaleOrderId()))
			return false;
		if (this.getStartCardSeqNo() == null) {
			if (other.getStartCardSeqNo() != null)
				return false;
		} else if (!this.getStartCardSeqNo().equals(other.getStartCardSeqNo()))
			return false;
		return true;
	}

}
